import { APASSSERVER, APASSSERVERBASE, HISTORY_MESSAGE_COUNT, LOGINSMS, INTERIOR, TRANSLATE } from "./constants";
import timRenderInstance from "./utils/timRenderInstance";
import { FriendProfile, GroupInfoCustemString, GroupMemberInfoCustemString, MsgSendMessageParamsV2, ModifyFriendProfileParams } from "im_electron_sdk/dist/interfaces"
import axios from 'axios'


// 登录
export const loginIn = (data) => {
  return axios({
    url: `${INTERIOR}/login`,
    method: 'post',
    data: data
  })
}
// 注册
export const create = (data) => {
  return axios({
    url: `${INTERIOR}/create`,
    method: 'post',
    data: data
  })
}
// 用户信息
export const userInfo = (data) => {
  const token = localStorage.getItem('token')
  return axios({
    url: `${INTERIOR}/user_info`,
    method: 'get',
    params: data,
    headers: {
      'Content-Type': 'application/json',
      'token': `${token}`
    }
  })
}
// 禁言 解除禁言
export const groupQuiet = (data) => {
  const token = localStorage.getItem('token')
  return axios({
    url: `${INTERIOR}/group_quiet`,
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'token': `${token}`
    }
  })
}

// 禁言列表
export const quietList = (data) => {
  const token = localStorage.getItem('token')
  return axios({
    url: `${INTERIOR}/group_quiet_list`,
    method: 'get',
    params: data,
    headers: {
      'Content-Type': 'application/json',
      'token': `${token}`
    }
  })
}
// 踢人 
export const kicking = async(data) => {
  const { groupId, identifier } = data
  const params = {
    group_delete_member_param_group_id: groupId,
    group_delete_member_param_identifier_array: [identifier]
  }
  const { code, data } = await timRenderInstance.TIMGroupDeleteMember({
    params
  })
  console.log(data);
  
}

// 获取翻译SDK token TRANSLATE
export const translateToken = () => {
  const AK = "mDyt84xSZFbWXUAHyGIBGLxI"
  const SK = "uoT2cjSjopb5trv4xrljU8B9Aj7W8orW"
  return axios({
    url: `${TRANSLATE}/oauth/2.0/token?grant_type=client_credentials`,
    method: 'post',
    params: {
      client_id: AK,
      client_secret: SK
    },
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    }
  })
}
